﻿

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>报名信息填写</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" />
    <link rel="stylesheet" href="css/xiaoyi.css">
    <link href="css/weui.min.css" rel="stylesheet" />
</head>
<body>
    <div class="enroll-box">
        <!--头部-->
        <header class="title-box">
            <img class="enroll-logo" src="pic/logo.png" alt="">
            <img class="enroll-title" src="pic/enroll-title.png" alt="">
            <img class="book1-rdown" src="pic/book1-rdown.png" alt="">
            <img class="book2-ldown" src="pic/book2-ldown.png" alt="">
            <img class="book3-rtop" src="pic/book3-rtop.png" alt="">
            <img class="book4-tmiddle" src="pic/book4-tmiddle.png" alt="">
            <!--title-->
            <div class="success-subtitle">
                <img src="pic/sign-subtitle.png" alt="">
            </div>
        </header>

        <form action="" class="form-box">

            <ul class="form-ul">
                <li class="form-selbox clear">
                    <select class="sign-stusel" id="ddl_area">
                        <option value="">请选择大区</option>
                    </select>
                    <select name="" class="sign-stusel" id="ddl_campus">
                        <option value="">请选择校区</option>
                    </select>
                </li>

                <li class="sign-address" id="txt_address">
                </li>

                <li class="form-selbox clear">
                    <select name="" class="sign-sel" id="ddl_term">
                        <option value="">请选择期数</option>
                    </select>
                </li>

                <li>
                    <ul class="sign-checkbox clear form-mar" id="ckb_subject"></ul>
                    <div class="form-subject-note">*入班后仅收取99元学杂费</div>
                </li>

                <li class="sign-tel clear">
                    <input class="sign-inp" autocomplete="off" placeholder="学生姓名" type="text" id="txt_stuname">
                </li>

                <li class="sign-tel clear">
                    <input type="text" autocomplete="off" placeholder="家长联系方式" id="txt_phone">
                </li>

                <li class="sign-code clear">
                    <input type="text" autocomplete="off" placeholder="手机验证码" id="txt_code">
                    <button type="button" id="btn_code">获取验证码</button>
                </li>

            </ul>

            <div class="clear pay-ul">
                <a href="javascript:" class="btn-pay-a" id="btn_submit">立即抢占学位</a>
            </div>
        </form>
    </div>

    <!--效果html结束-->
    <!--weui loading-->
    <div id="loadingToast" class="weui_loading_toast" style="display: none;">
        <div class="weui_mask_transparent"></div>
        <div class="weui_toast">
            <div class="weui_loading">
                <!-- :) -->
                <div class="weui_loading_leaf weui_loading_leaf_0"></div>
                <div class="weui_loading_leaf weui_loading_leaf_1"></div>
                <div class="weui_loading_leaf weui_loading_leaf_2"></div>
                <div class="weui_loading_leaf weui_loading_leaf_3"></div>
                <div class="weui_loading_leaf weui_loading_leaf_4"></div>
                <div class="weui_loading_leaf weui_loading_leaf_5"></div>
                <div class="weui_loading_leaf weui_loading_leaf_6"></div>
                <div class="weui_loading_leaf weui_loading_leaf_7"></div>
                <div class="weui_loading_leaf weui_loading_leaf_8"></div>
                <div class="weui_loading_leaf weui_loading_leaf_9"></div>
                <div class="weui_loading_leaf weui_loading_leaf_10"></div>
                <div class="weui_loading_leaf weui_loading_leaf_11"></div>
            </div>
            <p class="weui_toast_content">报名中...</p>
        </div>
    </div>

    <script src="js/jquery-3.1.1.min.js"></script>
    <script src="js/font.js"></script>
    <script src="js/publib.js"></script>
        <script src="js/jweixin-1.2.0.js"></script>
        <script type="text/javascript">
            var shareImg = 'https://sic.skl520.com/ContentAct/SumXc/images/min.png';
            var shareLink = 'https://sic.skl520.com/hd/SumXc';//分享显示页面New1
            var shareDesc = '现读一、三、六、九年级学生暑假来习，学费全免，敬请关注！';
            var shareTitle = '2018思考乐暑假班学费全免，0元学一夏';
            //------------微信js------------
            wx.config({
                debug: false,
                appId: 'wxe20ac759a1e49e97',
                timestamp: '1522240495',
                nonceStr: 'Wm3WZYTPz0wzccnW',
                signature: 'da9cd2796aa83c4d9d435de118f1e0df2573617c',
                jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage']
            });

            //分享朋友圈
            wx.ready(function () {
                wx.onMenuShareTimeline({
                    title: shareTitle,
                    link: shareLink,
                    imgUrl: shareImg,
                    success: function () {
                        $.post("/hd/New1Share", { gettype: 2 }, function (ajaxobj) {
                            showDialogTwo(ajaxobj.msg);
                            if (ajaxobj.status == 0) {
                                window.location = "https://sic.skl520.com/hd/New1Draw";
                            }
                        }, "json");
                    },
                    cancel: function () {
                    }
                });

                //分享给朋友
                wx.onMenuShareAppMessage({
                    title: shareTitle,
                    desc: shareDesc,
                    link: shareLink,
                    imgUrl: shareImg,
                    type: 'link',
                    dataUrl: '',
                    success: function () {
                        $.post("/hd/New1Share", { gettype: 3 }, function (ajaxobj) {
                            showDialogTwo(ajaxobj.msg);
                            if (ajaxobj.status == 0) {
                                window.location = "https://sic.skl520.com/hd/New1Draw";
                            }

                        }, "json");
                    },
                    cancel: function () {
                    }
                });
            });
        </script>
    <script>

    /*安卓软键盘输入遮挡输入框问题*/
    $(document).ready(function () {
        $('body').height($('body')[0].clientHeight);
    });

//所有数据
        var arr=[{"AreaName":"盐田区","caList":[{"Address":"盐田区梧桐路2002号沙头角林场桐华大厦3-4楼，咨询热线：25215521","CampusName":"盐田馆","Campusid":67,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"},{"Key":1002,"Value":"数学"}]}]}]}]},{"AreaName":"罗湖区","caList":[{"Address":"罗湖区东门北路2075号1栋2楼（竹园宾馆西侧），咨询热线：25600773","CampusName":"翠竹馆","Campusid":19,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]}]}]},{"Address":"罗湖区爱国路华深办公楼九栋3楼思考乐教育，咨询热线：88240674","CampusName":"螺岭馆","Campusid":49,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]}]}]}]},{"AreaName":"宝安区","caList":[{"Address":"宝安区新湖路天悦龙庭一楼（宝安中心教育城），咨询热线：28362399","CampusName":"宝中馆","Campusid":42,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"},{"Key":1002,"Value":"数学"}]}]}]}]},{"AreaName":"南山区","caList":[{"Address":"南山区世纪村弘文文化广场2楼，咨询热线：86088302","CampusName":"世纪馆","Campusid":43,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]}]}]},{"Address":"南山区南海大道青春家园七彩儿童世界二楼，咨询电话：88240682","CampusName":"蔚蓝馆","Campusid":88,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"}]}]}]},{"Address":"南山区正云路缤纷商业中心201A，咨询热线：88240693","CampusName":"麒麟馆","Campusid":39,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1002,"Value":"数学"},{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1002,"Value":"数学"},{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1002,"Value":"数学"},{"Key":1003,"Value":"英语"},{"Key":1001,"Value":"语文"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]}]}]}]},{"AreaName":"龙华新区","caList":[{"Address":"龙华新区民治街道光浩国际中心A座2楼，咨询热线：86701671","CampusName":"光浩国际馆","Campusid":61,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1001,"Value":"语文"},{"Key":1002,"Value":"数学"},{"Key":1003,"Value":"英语"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1002,"Value":"数学"},{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"}]}]}]}]},{"AreaName":"福田区","caList":[{"Address":"福田区红岭中路2033号301室（福田博爱医院对面），咨询热线：22952513","CampusName":"红岭馆","Campusid":38,"Phone":"","gradeList":[{"gradeid":1002,"gradename":"二年级","termList":[{"TermName":"新小二暑假1期（7.11-7.21）","Termid":61181,"subject":[{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假2期（7.22-8.1）","Termid":61182,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假3期（8.3-8.13）","Termid":61183,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]},{"TermName":"新小二暑假4期（8.15-8.25）","Termid":61184,"subject":[{"Key":1001,"Value":"语文"},{"Key":1003,"Value":"英语"},{"Key":1002,"Value":"数学"}]}]}]}]}];
        //分校数据
        var campus;
        //年级
        var grade;
        //期数
        var term;
        //当前科目数据
        var subject;

        //片区变动
        function areaChange(area){
            var areaopts='<option value="0">请选择片区</option>';
            for (var i = 0; i < arr.length; i++) {
                if(area==arr[i].AreaName){
                    areaopts= areaopts+("<option value='"+arr[i].AreaName+"' selected='selected'>"+arr[i].AreaName+"</option>");
                    campus=arr[i].caList;
                    campusChange();
                }
                else{
                    areaopts= areaopts+("<option value='"+arr[i].AreaName+"'>"+arr[i].AreaName+"</option>");
                }
            }
            $('#ddl_area').html(areaopts);
        }

        //分校变动
        function campusChange(campusid) {
            //alert('campus change');
            var caopts='<option value="0">请选择分校</option>';
            for (var i = 0; i < campus.length; i++) {
                if(campusid==campus[i].Campusid){
                    caopts+=("<option value='"+campus[i].Campusid+"' selected='selected'>"+campus[i].CampusName+"</option>");

                    $('#txt_address').html("地址:"+campus[i].Address+"[咨询热线:<a href='tel:"+campus[i].Phone+"'><u>"+campus[i].Phone+"</u></a>]");
                    grade=campus[i].gradeList;
                    gradeChange(1002);
                }
                else{
                    caopts+=("<option value='"+campus[i].Campusid+"'>"+campus[i].CampusName+"</option>");
                }
            }
            $('#ddl_campus').html(caopts);
        }

        //年级变动
        function gradeChange(gradeid) {
            //alert('grade change');
            var graopts='<option value="0">请选择年级</option>';
            for (var i = 0; i < grade.length; i++) {
                if(gradeid==grade[i].gradeid){
                    graopts+=("<option value='"+grade[i].gradeid+"' selected='selected'>"+grade[i].gradename+"</option>");
                    term=grade[i].termList;
                    termChange();
                }
                else{
                    graopts+=("<option value='"+grade[i].gradeid+"' >"+grade[i].gradename+"</option>");
                }
            }
            //$('#ddl_grade').html(graopts);
        }

        //期数
        function termChange(termid) {
            //alert('term change');
            var teropts='<option value="0">请选择期数</option>';
            var subopts='';
            for (var i = 0; i < term.length; i++) {
                if(termid==term[i].Termid){
                    teropts+= ("<option value='"+term[i].Termid+"' selected='selected'>"+term[i].TermName+"</option>");
                    //科目
                    for (var j = 0; j < term[i].subject.length; j++) {
                        subopts=subopts+"<li subjectid='"+term[i].subject[j].Key+"'>"+term[i].subject[j].Value+"</li>";
                    }

                }else {
                    teropts+= ("<option value='"+term[i].Termid+"'>"+term[i].TermName+"</option>");
                }
                $('#ddl_term').html(teropts);
                $('#ckb_subject').html(subopts);
            }
        }

        //合法性验证
        function dataValid() {

            //片区
            if ($("#ddl_area").val()==0) {
                showDialogTwo("请选择片区");
                return false;
            }

            //分校
            if ($("#ddl_campus").val()==0) {
                showDialogTwo("请选择分校");
                return false;
            }

            //期数
            if ($("#ddl_term").val()==0) {
                showDialogTwo("请选择期数");
                return false;
            }

            //科目
            if($('#ckb_subject>li.cur').length<=0){
                showDialogTwo("请至少选择一个科目");
                return false;
            }

            //科目
            if ($('#ckb_subject>li.cur').length > 2) {
                showDialogTwo("一个学员最多只能报两科");
                return false;
            }

            //姓名
            if ($('#txt_stuname').val() == "") {
                showDialogTwo("学员姓名不能为空");
                return false;
            }

            //在读学校
            if ($('#txt_school').val() == "") {
                showDialogTwo("学员在读学校不能为空");
                return false;
            }

            //电话
            var reg = /^1\d{10}$/;
            if ($('#txt_phone').val() == "" || reg.test($('#txt_phone').val()) == false) {
                showDialogTwo("电话号码不能为空且必须有效");
                return false;
            }

            //输入验证码
            if ($('#txt_code').val() == "") {
                showDialogTwo("必须输入手机验证码");
                return false;
            }
            return true;
        }

        //获取验证码
        var c = -1;
        function setTimes() {
            if (c < 0) {
                $('#btn_code').html("获取验证码");
                return;
            }
            $('#btn_code').html(c + "秒后重新获取");
            setTimeout(setTimes, 1000);
            c--;
        }

        //验证码
        $('#btn_code').click(function () {
            if (c < 0) {
                //验证数据合法性
                //姓名
                if ($('#txt_stuname').val() == "") {
                    showDialogTwo("学员姓名不能为空！");
                    return;
                }
                //电话
                var reg = /^1\d{10}$/;
                if ($('#txt_phone').val() == "" || reg.test($('#txt_phone').val()) == false) {
                    showDialogTwo("电话号码不能为空且必须有效！");
                    return;
                }
                //先异步请求判断该姓名配电话是否已经报名或者发送短信
                $.post('/hd/New1Sms',
                    {
                        stuname: $('#txt_stuname').val(),
                        phone: $('#txt_phone').val()
                    }
                    , function (ajaxobj) {
                        if (ajaxobj.status == 0) {
                            c = 60;
                            setTimes();
                        }
                        else {
                            showDialogTwo(ajaxobj.msg);
                        }
                    }, "json");
            }
        })

        $(function () {

            areaChange();

            //片区
            $('#ddl_area').change(function(){
                $('#ddl_grade').html("<option>请选择年级</option>");
                $('#ddl_campus').html("<option>请选择分校</option>");
                $('#lal_address,#chk_subject').html('');
                areaChange($(this).val());
            });

            //分校变动
            $("#ddl_campus").change(function () {                
                campusChange($(this).val());
                //gradeChange(1001);
                $("#ckb_subject").html();
            });

            //年级选择变动
            //$('#ddl_grade').change(function(){
            //    gradeChange(1001);
            //    $("#ckb_subject").html();
            //})

            //期数选择变动
            $('#ddl_term').change(function(){
                termChange($(this).val());
                $("#ckb_subject").html();
            })

            //选科目选择变动
            $("#ckb_subject").on("click","li",function () {
                if (!$(this).hasClass("cur")) {
                    $(this).addClass("cur");
                } else {
                    $(this).removeClass("cur");
                }
            });

            $("#btn_submit").click(function () {
                if (dataValid()) {
                    $('.weui_loading_toast').show();

                    //学科
                    var xk=$('#ckb_subject li.cur');
                    var subjectnames='';
                    var subjectid='';
                    for (var i = 0; i < xk.length; i++) {
                        subjectnames+=($(xk[i]).html()+",");
                        subjectid+= ($(xk[i]).attr("subjectid")+",");
                    }

                    var parms = {
                        actid: $("#ddl_term").val(),
                        campusid:$("#ddl_campus").val(),
                        campusname:$("#ddl_campus option:selected").html(),

                        subjects:subjectid,
                        subjectnames:subjectnames,

                        stuname: $("#txt_stuname").val(),
                        phone: $("#txt_phone").val(),

                        code:$("#txt_code").val(),
                        ad: ''
                    };

                    //提交
                    $.post('/hd/New1Data',parms,function(ajaxobj){

                        $('.weui_loading_toast').hide();
                        if(ajaxobj.status==0){
                            //跳转成页
                            window.location.href = 'https://sic.skl520.com/hd/New1Success/' +ajaxobj.data;
                        }
                        else{
                            showDialogTwo(ajaxobj.msg);
                        }
                    },"json")
                }
            });

        });
    </script>


</body>
</html>

